<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\store\model\meal;

use app\common\model\meal\MenuRel as MenuRelModel;

/**
 * 商品与分类关系模型
 * Class MenuRel
 * @package app\store\model
 */
class MenuRel extends MenuRelModel
{
    public function getList($menuId, $type)
    {
        $list = $this->with('foods.images.file')->alias('rel')
        ->join('foods f','f.foods_id=rel.foods_id')
            ->where('rel.menu_id', $menuId)
            ->where('rel.type', $type)
            ->where('f.status',10)
            ->select()->toArray();
        $lists = [];
        foreach ($list as $key => $value) {
            $dd['goods_image']     = $value['foods']['images'][0]['file']['preview_url'];
            $dd['image_id']        = $value['foods']['images'][0]['file']['file_id'];
            $dd['goods_price_min'] = $value['foods']['goods_price_min'];
            $dd['goods_name']      = $value['foods']['goods_name'];
            $dd['id']              = $value['id'];
            $dd['goods_num']       = $value['goods_num'];
            $dd['type']            = $value['type'];
            $dd['foods_id']        = $value['foods_id'];
            $lists[]               = $dd;

        }

        return $lists;

    }
}
